package com.payfen.service.impl;

import java.util.List;
import java.util.Map;

import com.payfen.client.jsonbean.ResultBean;
import com.payfen.dao.inf.ShopsUserDao;
import com.payfen.service.inf.ShopsUserService;
import com.payfen.util.Tool;

public class ShopsUserServiceImpl extends Service implements ShopsUserService {

	private ShopsUserDao shopsUserDao;

	public String shopsUserLogin(Map<String, String> map) {
		String resultMsg = "";
		String shopsPassword = Tool.getMapValue(map, "shopsPassword");
		try {
			List<Map<String,String>> shopsUserList = this.shopsUserDao.queryByLogin(map);
			if (shopsUserList == null && shopsUserList.size() > 0) {
				resultMsg = ResultBean.createReturnJson("0003", this.getErrorCode("0003"),null);
			} else {
				Map<String,String> su = (Map<String,String>)shopsUserList.get(0);
				
				if (su.get("shopPassword").trim().equals(shopsPassword)) {
					resultMsg = ResultBean.createReturnJson("0000", this.getErrorCode("0002"),null);
				} else {
					resultMsg = ResultBean.createReturnJson("0001", this.getErrorCode("0001"),null);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			resultMsg = ResultBean.createReturnJson("0002", this.getErrorCode("0002"),null);
		}
		return resultMsg;
	}

	public void setShopsUserDao(ShopsUserDao shopsUserDao) {
		this.shopsUserDao = shopsUserDao;
	}

}
